//获取一张狗的图片:保存的数据
import {onMounted, ref} from "vue";
import axios from "axios";

const useShowDog = () => {
    const dogUrl = ref("");
    const loading = ref(true);
    //获取一张狗的图片:发送请求
    const getDogUrl = async () => {
        const result = await axios.get("https://dog.ceo/api/breeds/image/random");
        loading.value = false;
        dogUrl.value = result.data.message;
    };

    //获取一张狗的图片:生命周期函数
    onMounted(() => {
        getDogUrl();
    });

    return {
        dogUrl,
        loading
    }
}


export default useShowDog